
# 9-9乘法表，for循环4种情况；while循环4种情况。

# for循环，左下位置
for i in range(1,10):
    for j in range(1,i+1):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
    print("")
print("="*90)


# for循环，左上位置
for i in range(9,0,-1):
    for j in range(1,i+1):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
    print("")
print("="*90)


# for循环，右下位置
for i in range(1,10):
    for k in range(1,10-i):
        print(end="         ")
    for j in range(i,0,-1):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
    print("")
print("="*90)


# for循环，右上位置
for i in range(9,0,-1):
    for j in range(i,0,-1):
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
    print("")
    for k in range(10,i,-1):
        print(end="         ")
          


# while循环，左下位置
i = 1
while i <= 9:
    j = 1
    while j < i + 1:
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
        j += 1
    i += 1
    print("")
print("="*90)


# while循环，左上位置
i = 9
while i >= 1:
    j = 1
    while j < i + 1:
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
        j += 1
    i -= 1
    print("")
print("="*90)


# while循环，右下位置
i = 1
while i <= 9:
    j = i
    k = 1
    while k < 10-i:
        print(end="         ")
        k += 1
    while j >= 1:
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
        j -= 1
    print("")
    i += 1
print("="*90)


# while循环，右上位置
i = 9
while i >= 1:
    j = i
    k = 1
    while j >= 1:
        print("{}*{}={:<4}".format(j,i,i*j),end=" ")
        j -= 1
    print("")
    i -= 1
    while k < 10-i:
        print(end="         ")
        k += 1
